package d_decrator.a_origin;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wug on 2016/6/22 0022.
 */
public class ShopManager {
    private List<Component> componentList = new ArrayList<>();

    public int getPrice() {
        int sum=0;
        for (int i = 0; i < componentList.size(); i++) {
            Component component = componentList.get(i);
            sum += component.getPrice();
        }
        return sum;
    }

    public String getConfiguration() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < componentList.size(); i++) {
            sb.append(componentList.get(i).getDesc() + "\t" + componentList.get(i).getPrice() + "\n");
        }
        return sb.toString();
    }

    public void add(Component component) {
        componentList.add(component);
    }
}
